<?php
/**
 * Task Information Form
 * 
 * 
 */
use Shama\Task;
use Fox\Generator;
use Fox\Dao\SqlFragment;
use Fox\Html\DropList;
use Fox\Html\Input;
use Doctrine\DBAL\Schema\Index;
use Fox\Html\TextArea;

$xview = Xview::instance();
$authorize = true;
$reference_class = $xview->val('reference_class');
$reference_id = $xview->val('reference_id');
$reference_label = $xview->val('reference_label');

$block = new Fox\Html\Block('bTask');
$block->add(new Input(array('task_subject','subject'),true))
		->colspan(2)
		->size(40);
$block->add(new Input('estimate_duedate',true));
// Task Status
$finder = new Task\Status();
$status = $finder->find(new SqlFragment('language = ?',array($xview->language())),array('label' => false));
$block->add(new DropList(array('task_status','status'),null,null,null,Task\Status::TYPE_NEW),2,'estimate_duedate')
	  ->options($status,'status','label');
// Task Priority
$finder = new Task\Priority();
$priorities = $finder->find(new SqlFragment('language = ?',array($xview->language())));
$block->add(new DropList(array('task_priority','priority')))->options($priorities,'priority','label');
// Task Type
$finder = new Task\Type();
$types = $finder->find(new SqlFragment('language = ?',array($xview->language())));
$block->add(new DropList(array('task_type','type')),2,'priority')
	  ->options($types,'typeid','label');

// Status

// Related User 
$defaultUser = User::current()->getId();
$users = $xview->application()->users();
$block->add(new DropList(array('assign_to','assigned_to'),true,false,false,$defaultUser),2)
	  ->input($authorize)
	  ->options($users,'idusr',Generator::concatenate(
	  							Generator::useAttribute('fname'),
	  							 Fox\Generator::useAttribute('lname'), ' '))
	  ;
	  
// Related To Object 
/*
$finder = new Task\Reference();
$references = $finder->find(new SqlFragment('language = ?',array($xview->language())));
$block->add(new DropList(array('task_ref_object','reference_class')),2)
	  ->input($authorize)
	  ->options($references,'reference','label')
	  ;
// Related To Object Label
$block->add(new DropList(array('task_reference','reference_id'),true),2)
		->input($authorize);
		
if(!empty($reference_class) && !empty($reference_id) && $reference_label)
{
	$block->item('reference_id')->options(array($reference_id => $reference_label));
}
*/
$block->add(new TextArea('comment'))
		->colspan(2);
$block->labelSize(100);
return $block;